"""add order and seckill model

Revision ID: 151b2b10cb48
Revises: 
Create Date: 2025-08-23 19:34:41.007244

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '151b2b10cb48'
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('commodity',
    sa.Column('title', sa.String(length=255), nullable=False),
    sa.Column('price', sa.DECIMAL(precision=10, scale=2), nullable=True),
    sa.Column('covers', sa.JSON(), nullable=True),
    sa.Column('detail', sa.Text(), nullable=True),
    sa.Column('created_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.BigInteger(), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('seckill',
    sa.Column('sk_price', sa.DECIMAL(precision=10, scale=2), nullable=True, comment='秒杀价格'),
    sa.Column('start_time', sa.DateTime(), nullable=True, comment='秒杀开始时间'),
    sa.Column('end_time', sa.DateTime(), nullable=True, comment='秒杀结束时间'),
    sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
    sa.Column('max_sk_count', sa.Integer(), nullable=True, comment='最大秒杀数量'),
    sa.Column('sk_per_max_count', sa.Integer(), nullable=True, comment='每秒最大秒杀数量'),
    sa.Column('commondity_id', sa.BigInteger(), nullable=True, comment='商品id'),
    sa.Column('id', sa.BigInteger(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['commondity_id'], ['commodity.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('order',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('status', sa.Enum('UNPAYED', 'PAYED', 'TRANSIT', 'FINISHED', 'REFUNDING', 'REFUNDED', name='orderstatusenum'), nullable=True),
    sa.Column('count', sa.Integer(), nullable=True),
    sa.Column('amount', sa.DECIMAL(precision=10, scale=2), nullable=True),
    sa.Column('user_id', sa.BigInteger(), nullable=True),
    sa.Column('address_id', sa.String(length=255), nullable=True),
    sa.Column('seckill_id', sa.BigInteger(), nullable=True),
    sa.Column('id', sa.BigInteger(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['seckill_id'], ['seckill.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('order')
    op.drop_table('seckill')
    op.drop_table('commodity')
    # ### end Alembic commands ###
